//
//  Global.swift
//  interview
//
//  Created by Mac on 2019/8/10.
//  Copyright © 2019 计海峰. All rights reserved.
//

import Foundation
import UIKit

//MARK: - 全局尺寸
public struct Screen {
    
    public static let width = UIScreen.main.bounds.size.width
    
    public static let height = UIScreen.main.bounds.size.height
    
    public static let navBarHeight: CGFloat = 44.0
    
    public static let statusBarHeight = UIApplication.shared.statusBarFrame.height
    
    public static let topBarHeight = navBarHeight + statusBarHeight
    
    public static let tabBarHeight: CGFloat = 49.0
    
    public static let bottomBarHeight : CGFloat = UIApplication.shared.statusBarFrame.height > 20.0 ? 34.0 : 0.0
    
    public static let tabBottomBarHeight = tabBarHeight + bottomBarHeight
    
}

// 设备信息
public struct DeviceInfo {
    
    public static var iOSVersion: String { // iOS版本
        return UIDevice.current.systemVersion
    }
    
    public static var identifierNumber: String { // 设备uuid
        return UIDevice.current.identifierForVendor?.uuidString ?? ""
    }
    
    public static var systemName: String { // 设备名称
        return UIDevice.current.systemName
    }
    
    public static var model: String { // 设备型号
        return UIDevice.current.systemName
    }
    
    public static var modelName: String { // 设备具体型号
        return UIDevice.modelName
    }
    
    public static var localizedModel: String { // 设备具体型号
        return UIDevice.current.localizedModel
    }
    
}

// 工程信息
public struct BundleInfo {
    
    public static let infoDictionary = Bundle.main.infoDictionary!
    
    public static var identifier: String { // identifier
        return valueString("CFBundleIdentifier") 
    }
    
    public static var name: String { // bundle name
        return valueString("CFBundleName")
    }
    
    public static var displayName: String { // display name
        return valueString("CFBundleDisplayName")
    }
    
    public static var majorVersion: String { // short version
        return valueString("CFBundleShortVersionString")
    }
    
    public static var  minorVersion: String { // version
        return valueString("CFBundleVersion")
    }
    
    static private func valueString(_ keyName : String) -> String {
        guard let name = infoDictionary[keyName] else {
            return ""
        }
        return name as! String
    }
    
}
